package org.nepu.scr.indexrate.converter.drillingrate.facilitystructure;

import cn.hutool.json.JSONUtil;
import org.nepu.scr.indexrate.vo.drillingrate.facilitystructure.FacilityStructure;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;

@Convert
public class FacilityStructureConverter implements AttributeConverter<FacilityStructure, String> {
    @Override
    public String convertToDatabaseColumn(FacilityStructure facilityStructure) {
        return JSONUtil.toJsonStr(facilityStructure);
    }

    @Override
    public FacilityStructure convertToEntityAttribute(String s) {
        return JSONUtil.toBean(s, FacilityStructure.class);
    }
}
